/*
 * @Author: 詹真琦(legendryztachi@gmail.com)
 * @Date: 2021-11-11 18:04:38
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-12-13 18:19:37
 * @FilePath: \pc-collaboration\src\api\modules\send.api.js
 * @Description: 发送、保存待发等相关接口
 */
import globalMethods from "@/plugins/methods";
import globalData from "@/plugins/data";

export default ({ service, request, tools }) => ({
    /**
     * @description: 发送
     */
    send(data) {
        return request({
            url: `/new/send`,
            method: 'post',
            data,
        });
    },
    /**
     * @description: 保存待发
     */
    draft(data) {
        return request({
            url: `/new/draft`,
            method: 'post',
            data,
        });
    },
    /**
     * @description: 存为模板
     */
    saveAsTemplate(data) {
        return request({
            url: `/new/template`,
            method: 'post',
            data,
        });
    },

    /**
     * 快速选人
     * @param checked
     * @returns {*}
     */
    tokenInput() {
        return request({
            url: `${globalMethods.getLocationOrigin()}${globalData.ctxPath}/organization/orgIndexController.do?method=getRecentData`,
            method: 'get',
            params: {
                accessFileSecretLevel: window.getAccessFileSecretLevel(),
                time: Math.random(),
            },
        });
    },

    /**
     * 快速选人复制粘贴
     * @param copyValue 通过ctr+v 粘贴的内容
     * @return {*}
     */
    tokenInputFromCopy(copyValue) {
        return request({
            url: `${globalMethods.getLocationOrigin()}${globalData.ctxPath}/organization/orgIndexController.do`,
            method: 'post',
            params: {
                method: 'checkFromCopy',
                accessFileSecretLevel: window.getAccessFileSecretLevel(),
                time: Math.random(),
            },
            data: `cData= ${copyValue}`
        });
    },
    
    /**
     * 快速选人带搜索
     * @param userName
     * @returns {*}
     */
    tokenInputSearch(userName) {
        return request({
            url: `${globalMethods.getLocationOrigin()}${globalData.ctxPath}/organization/orgIndexController.do?method=searchMember`,
            method: 'get',
            params: {
                accessFileSecretLevel: window.getAccessFileSecretLevel(),
                key:userName,
                time: Math.random(),
            },
        });
    },
    
    /**
    * 快速选人结果回填成工作流流程图渲染可接收的对象
    * */
    tokenInputParse(data) {
        return request({
            url: `${globalMethods.getLocationOrigin()}${globalData.ctxPath}/rest/ctp/selectorg/panel/parse?option.n_a_s=1`,
            method: 'post',
            params: {
                accessFileSecretLevel: window.getAccessFileSecretLevel(),
                time: Math.random(),
            },
            data
        });
    },
    /**
    * 关联人员
    * */
    relativeMemberList(){
        return request({
            url: `${globalMethods.getLocationOrigin()}${globalData.ctxPath}/ajax.do`,
            method: 'post',
            params: {
                method: 'ajaxAction',
                managerName: 'colManager',
                rnd: Math.random(),
            },
            data: 'managerMethod=getRelativeMembers&arguments=[]',
        });
    },
    /**
     * 最近使用的模版
     * */
    getRecentTemplateList(){
        return request({
            url: `${globalMethods.getLocationOrigin()}${globalData.ctxPath}/ajax.do`,
            method: 'post',
            params: {
                method: 'ajaxAction',
                managerName: 'templateManager',
                rnd: Math.random(),
            },
            data: 'managerMethod=getRecentTemplateVos&arguments=["1,2,-1",10]',
        });
    }
});
